<!DOCTYPE html>
<html>
<head>
    {include file="_Fragment/meta" /}
    <link rel="stylesheet" href="/static/pear/component/pear/css/pear.css" />
    <link rel="stylesheet" href="/static/pear/admin/css/other/console1.css" />
</head>
<body class="pear-container">
<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form" action="">
            <div class="layui-form-item">

                <div class="layui-form-item layui-inline">
                    <div class="layui-input-inline">
                        <select name="type">
                            <option value="">章节类型</option>
                            <option value="1">图文</option>
                            <option value="2">文档</option>
                            <option value="3">测试</option>
                            <option value="4">Survey</option>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item layui-inline">
                    <div class="layui-input-inline">
                        <input type="text" name="title"  placeholder="请输入章节名称" class="layui-input" autocomplete="off">
                    </div>
                </div>
                <div class="layui-form-item layui-inline">
                    <button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="user-query">
                        <i class="layui-icon layui-icon-search"></i>
                        查询
                    </button>
                    <button type="reset" class="pear-btn pear-btn-md">
                        <i class="layui-icon layui-icon-refresh"></i>
                        重置
                    </button>
                </div>
            </div>
        </form>
    </div>
</div>
<div class="layui-card">
    <div class="layui-card-body">
        <table id="user-table" lay-filter="user-table"></table>
    </div>
</div>
{include file="_Fragment/javascript" /}
<script>
    layui.use(['table', 'form', 'jquery'], function() {
        let table = layui.table;
        let form = layui.form;
        let $ = layui.jquery;
        let userid = "{$userid}";
        let learning_id = "{$learning_id}";

        let cols = [
            [
                {
                    title: '章节',
                    field: 'title',
                    align: 'center',
                },
                {
                    title: '类型',
                    field: 'type_name',
                    align: 'center',
                },
                {
                    title: '开始学习时间',
                    field: 'start_time',
                    align: 'center',
                },
                {
                    title: '学习时长(s)',
                    field:'learning_time',
                    align: 'center',
                },
                {
                    title: '学习状态',
                    field:'status_name',
                    align: 'center',
                },
                {
                    title: '完成时间',
                    field:'end_time',
                    align: 'center',
                }
            ]
        ]

        table.render({
            elem: '#user-table',
            url: '/MembersTotal/getLearningViewList?userid='+userid+'&learning_id='+learning_id,
            page: {layout:['count', 'prev', 'page', 'next', 'skip']},
            limit: 5,
            cols: cols,
            //skin: 'line',
            toolbar: '#user-toolbar',
            defaultToolbar: [{
                title: '刷新',
                layEvent: 'refresh',
                icon: 'layui-icon-refresh',
            }, 'filter']
        });
        form.on('submit(user-query)', function(data) {
            table.reload('user-table', {
                where: data.field
                ,page: {
                    curr: 1, //重新从第 1 页开始
                    layout:['count', 'prev', 'page', 'next', 'skip']
                }
                ,limit: 5,
            })
            return false;
        });




        table.on('toolbar(user-table)', function(obj) {
            if (obj.event === 'refresh') {
                window.refresh();
            }
        });


        window.refresh = function(param) {
            table.reload('user-table');
        }

    })
</script>
</body>
</html>
